package com.example.shiro.controller;

import com.example.shiro.entity.User;
import com.example.shiro.service.UserService;
import com.example.shiro.util.ApiResult;
import com.example.shiro.util.ResultCodeEnum;
import com.example.shiro.util.ResultGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lijilong
 * @version 1.0
 * @Description:
 * @CreateDate 2018/7/5 11:06
 */
@Slf4j
@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    UserService userService;


    @GetMapping("/getUser")
    public ApiResult<User> getUser(String username){
        User user = userService.findByUserName(username);
        return ResultGenerator.getSuccessResult(user);
    }

    @GetMapping("/test")
    public ApiResult test(){
        return ResultGenerator.getSuccessResult();
    }

}
